package com.wyl.xue.admin.system.mybatis.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyl.xue.admin.system.mybatis.entity.SystemUsers;
import com.wyl.xue.admin.system.mybatis.mapper.SystemUsersMapper;
import com.wyl.xue.admin.system.mybatis.service.SystemUsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ClassName: SystemUsersServiceImpl
 * @Function: 用户
 * @Date: 2019/12/18 22:10
 * @author wyl
 * @version V1.0
 */
@Service
@Slf4j
@DS("master")
public class SystemUsersServiceImpl extends ServiceImpl<SystemUsersMapper, SystemUsers> implements SystemUsersService {


    /**
     * @Description 通过用户名获取用户信息
     * @param userName
     * @return com.wyl.xue.admin.system.mybatis.entity.SystemUsers
     * @Date 2020/11/13 17:04
     * @Author wangyl
     * @Version V1.0
     */
    @Override
    public SystemUsers getSystemUserInfoByUserName(String userName) {
        LambdaQueryWrapper<SystemUsers> queryWrapper = Wrappers.lambdaQuery(SystemUsers.class)
                                                               .eq(SystemUsers::getUsername, userName);
        return this.getOne(queryWrapper);
    }

    /**
     * @Description 通过部门id获取用户信息
     * @param departmentId
     * @return java.util.List<com.wyl.xue.admin.system.mybatis.entity.SystemUsers>
     * @Date 2020/11/13 17:20
     * @Author wangyl
     * @Version V1.0
     */
    @Override
    public List<SystemUsers> getSystemUsersByDepartmentId(long departmentId) {
        LambdaQueryWrapper<SystemUsers> systemUsersLambdaQueryWrapper = Wrappers.lambdaQuery(SystemUsers.class)
                                                                                .eq(SystemUsers::getDepartmentId, departmentId);
        return list(systemUsersLambdaQueryWrapper);
    }

}

